﻿Option Strict On

Imports System.Data
Imports System.Data.Common
Imports DbDataLib

Namespace Services

    Public MustInherit Class ServiceClass

        Protected WithEvents _dataService As DbDataService
        Protected WithEvents _ilog As log4net.ILog

        Friend Sub New(ByVal dataService As DbDataService)
            _dataService = dataService
            _ilog = log4net.LogManager.GetLogger(GetType(ServiceClass))
        End Sub

        Protected Overridable Function GetLastInsertId() As Integer
            Dim cmd As DbCommand = _dataService.Factory.CreateCommand()
            cmd.CommandText = "SELECT last_insert_id()"
            Return CInt(_dataService.ExecuteScalar(cmd))
        End Function

    End Class

End Namespace